package com.dsh.subscribe.service.impl;

import com.dsh.subscribe.dao.InsuranceCodeDao;
import com.dsh.subscribe.entity.HealthCareProgram;
import com.dsh.subscribe.entity.vo.InsuranceCodeVo;
import com.dsh.subscribe.service.InsuranceCodeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class InsuranceCodeImpl implements InsuranceCodeService {
    @Autowired
    InsuranceCodeDao insuranceCodeDao;
    @Override
    public PageInfo<InsuranceCodeVo> selectInsuranceCode(String projectName, String typeName, int limit, int page) {
        PageHelper.startPage(page,limit);
        if ((projectName == null) && (typeName == null)) {
            List<InsuranceCodeVo> insuranceCodeVos = insuranceCodeDao.selectInsuranceCode();
            return new PageInfo<>(insuranceCodeVos);
        }
        else {
            List<InsuranceCodeVo> insuranceCodeVos = insuranceCodeDao.selectInsuranceCodeM(projectName, typeName);
            return new PageInfo<>(insuranceCodeVos);
        }
    }

    @Override
    public PageInfo<InsuranceCodeVo> selectOtherInsuranceCode(String projectName, String typeName, int limit, int page) {
        PageHelper.startPage(page,limit);
        if ((projectName == null) && (typeName == null)) {
            List<InsuranceCodeVo> insuranceCodeVos = insuranceCodeDao.selectOtherInsuranceCode();
            return new PageInfo<>(insuranceCodeVos);
        }
        else {
            List<InsuranceCodeVo> insuranceCodeVos = insuranceCodeDao.selectOtherInsuranceCodeM(projectName, typeName);
            return new PageInfo<>(insuranceCodeVos);
        }
    }
}
